const sequelize = require("./index");
const { DataTypes } = require("Sequelize");

const BookListModule = sequelize.define(
  "dzl_BookListModule",
  {
    book_list_id: {
      type: DataTypes.CHAR,
      allowNull: false,
      primaryKey: true,
    },
    book_id: {
      type: DataTypes.CHAR,
      allowNull: false,
      primaryKey: true,
    },
    book_list_name: {
      type: DataTypes.CHAR,
      allowNull: false,
    },
    // TEXT('long') -> mysql中的LONGTEXT类型
    cover: {
      type: DataTypes.TEXT("long"),
      allowNull: true,
    },
  },
  {
    tableName: "booklist",
    // timestamps: true,
  }
);

const promise = BookListModule.sync({ alter: true });
promise.then(
  (success) => {
    console.log("BookListModule模型同步成功", success);
  },
  (fail) => {
    console.log("BookListModule模型同步失败", fail);
  }
);

module.exports = BookListModule;
